package fr.imag.ufrima.ctte.gui.toolbars;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JToolBar;

import fr.imag.ufrima.ctte.ImagCTTE;

public class DiagramEditorOrganizeToolBar extends JToolBar {
	private ImagCTTE imagCTTE;
	/**
	 * Constructor
	 */
	public DiagramEditorOrganizeToolBar(ImagCTTE imagCTTE){
		this.imagCTTE = imagCTTE;
		InitComponents();
	}
	/**
	 * Initialize components
	 */
	protected void InitComponents(){
		tlbFold = new javax.swing.JButton();
        tlbIncreaseDistance = new javax.swing.JButton();
        tlbDecreaseDistance = new javax.swing.JButton();
        
        tlbFold.setFocusable(false);
        tlbFold.setToolTipText("Fold/Unfold SubTree");        
        tlbFold.setIcon(new javax.swing.ImageIcon("images\\fold.png"));        
        this.add(tlbFold);
        
        tlbIncreaseDistance.setFocusable(false);
        tlbIncreaseDistance.setToolTipText("Increase Distance Between Levels");        
        tlbIncreaseDistance.setIcon(new javax.swing.ImageIcon("images\\rise.gif"));
        tlbIncreaseDistance.addActionListener(new ActionListener(){        	
        	public void actionPerformed(ActionEvent arg0) {
        		if (imagCTTE != null) {
        			imagCTTE.getCurrentTaskDiagram()
        				.setInterLevelDistance(imagCTTE.getCurrentTaskDiagram().getInterLevelDistance()+1);
        		}
        	}
        });
        this.add(tlbIncreaseDistance);
        
        tlbDecreaseDistance.setFocusable(false);
        tlbDecreaseDistance.setToolTipText("Decrease Distance Between Levels");        
        tlbDecreaseDistance.setIcon(new javax.swing.ImageIcon("images\\unrise.gif"));        
        tlbDecreaseDistance.addActionListener(new ActionListener(){        	
        	public void actionPerformed(ActionEvent arg0) {
        		if (imagCTTE != null) {
        			imagCTTE.getCurrentTaskDiagram()
        				.setInterLevelDistance(imagCTTE.getCurrentTaskDiagram().getInterLevelDistance()-1);
        		}
        	}
        });

        this.add(tlbDecreaseDistance);
	}
	/**
	 * Components
	 */
	private javax.swing.JButton tlbFold;
    private javax.swing.JButton tlbIncreaseDistance;
    private javax.swing.JButton tlbDecreaseDistance;
}
